package logic

import (
	"baidu-dev/models"
	"context"

	"baidu-dev/baidurpc/baidurpc"
	"baidu-dev/baidurpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type VideoDetailLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewVideoDetailLogic(ctx context.Context, svcCtx *svc.ServiceContext) *VideoDetailLogic {
	return &VideoDetailLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 视频详情
func (l *VideoDetailLogic) VideoDetail(in *baidurpc.VideoDetailRequest) (*baidurpc.VideoDetailResponse, error) {
	// todo: add your logic here and delete this line

	var video models.Video
	if err := video.VideoDetail(models.DB, in.VideoId); err != nil {
		return nil, err
	}

	return &baidurpc.VideoDetailResponse{
		UserId:    int64(video.UserId),
		Title:     video.Title,
		Category:  video.Category,
		VideoLink: video.VideoLink,
		CoverLink: video.CoverLink,
	}, nil
}
